package gameManager;

import java.awt.Dimension;
import java.awt.Point;

/**
 * Ammo shot by the player's gun in RecWars.
 * @author Stephen
 *
 */
public class PlayerAmmo extends AmmunitionObject{

    /**
     * Constructor.
     * @param startPosition Position for ammo to spawn
     * @param direction direction the ammo flies in
     */
    public PlayerAmmo (Point startPosition,
            int direction) {
        super(startPosition, direction);
        setDimension(new Dimension(30,15));
        setObjectImage("playerAmmo.jpg"); //Change this
        setSpeed(10);
        addCollisionObject("EnemyMoving");
        addCollisionObject("EnemyStaticBoss");
        setNameOfInteractable("PlayerAmmo");
        setHealthValue(1);
    }

    /**
     * Returns true if the ammo should disappear.
     */
    @Override
    public boolean isDying () {
        return (getHealthValue() <= 0);
    }

    /**
     * Describes what happens when the ammo hits something.
     */
    @Override
    public void collisionHandler (Interactable collisionCharacter) {
        for (String s : getNamesOfInteractableCanCollideWith()){
            if(s.equals(collisionCharacter.getNameOfInteractable())){
                setHealthValue(0);
            }
        }
    }
}